package game.module.club.logic;

import game.HallServer;
import game.module.club.bean.Club;
import game.module.club.bean.ClubApply;
import game.module.club.bean.ClubCodeBean;
import game.module.club.bean.ClubDonateDetail;
import game.module.club.bean.ClubInviteBean;
import game.module.club.bean.ClubMember;
import game.module.club.dao.ClubDao;

/**
 * @author: Pomelo.Lee
 * @date: 2017年8月29日 下午5:10:17
 */
public class ClubDaoHelper {

	static class SingletonHolder {
		static ClubDaoHelper instance = new ClubDaoHelper();
	}

	public static ClubDaoHelper getInstance() {
		return SingletonHolder.instance;
	}

	public void asyncSaveClub(final Club club) {
		HallServer.executorService.execute(new Runnable() {
			@Override
			public void run() {
				ClubDao.getInstance().saveClub(club);
			}
		});
	}

	public void asyncDissolveClubMember(int clubId) {
		HallServer.executorService.execute(new Runnable() {
			@Override
			public void run() {
				ClubDao.getInstance().delClubMemberByClubId(clubId);
			}
		});
	}

	public void asyncSaveClubMember(final ClubMember clubMember) {
		HallServer.executorService.execute(new Runnable() {
			@Override
			public void run() {
				ClubDao.getInstance().saveClubMember(clubMember);
			}
		});
	}

	public void asyncSaveUsedName(final String clubName) {
		HallServer.executorService.execute(new Runnable() {
			@Override
			public void run() {
				ClubDao.getInstance().addClubNameUsed(clubName);
			}
		});
	}

	public void asyncUpdateClubCode(final ClubCodeBean bean) {
		HallServer.executorService.execute(new Runnable() {
			@Override
			public void run() {
				ClubDao.getInstance().updateClubCodeBean(bean);
			}
		});
	}

	public void asyncSaveClubApply(final ClubApply bean) {
		HallServer.executorService.execute(new Runnable() {
			@Override
			public void run() {
				ClubDao.getInstance().saveClubApply(bean);
			}
		});
	}

	public void asyncSaveClubDonateDetail(final ClubDonateDetail bean) {
		HallServer.executorService.execute(new Runnable() {
			@Override
			public void run() {
				ClubDao.getInstance().saveClubDonateDetail(bean);
			}
		});
	}

	public void asyncUpdateClubBean(final Club bean) {
		HallServer.executorService.execute(new Runnable() {
			@Override
			public void run() {
				ClubDao.getInstance().updateClubBean(bean);
			}
		});
	}

	public void asyncDelClubBean(final Club bean) {
		HallServer.executorService.execute(new Runnable() {
			@Override
			public void run() {
				ClubDao.getInstance().delClubBean(bean);
			}
		});
	}

	public void asyncDelClubMemberByPlayerId(final int playerId) {
		HallServer.executorService.execute(new Runnable() {
			@Override
			public void run() {
				ClubDao.getInstance().delClubMemberByPlayerId(playerId);
			}
		});
	}

	public void asynUpdateClubMember(final ClubMember clubMember) {
		HallServer.executorService.execute(new Runnable() {
			@Override
			public void run() {
				ClubDao.getInstance().updateClubMemberBean(clubMember);
			}
		});
	}

	public void asynDelClubApplyByPlayerId(final int playerId) {
		HallServer.executorService.execute(new Runnable() {
			@Override
			public void run() {
				ClubDao.getInstance().delClubApplyByPlayerId(playerId);
			}
		});
	}

	public void asyncDelClubApplyByPlayerIdAndClubId(final int playerId, final int clubId) {
		HallServer.executorService.execute(new Runnable() {
			@Override
			public void run() {
				ClubDao.getInstance().delClubApplyByPlayerIdAndClubId(playerId, clubId);
			}
		});
	}

	public void asyncSaveClubInvite(final ClubInviteBean bean) {
		HallServer.executorService.execute(new Runnable() {
			@Override
			public void run() {
				ClubDao.getInstance().saveClubInviteBean(bean);
			}
		});
	}

	public void asyncUpdateClubInvite(int id, int status) {
		HallServer.executorService.execute(new Runnable() {
			@Override
			public void run() {
				ClubDao.getInstance().updateClubInvite(id, status);
			}
		});
	}

}
